home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
SDDOS.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-01-13
|
62KB
|
1,811 lines
CODE SEGMENT
Org 0100
Main:
Jmp Install
;---------------------------------------------------------------------------;
; ;
; Data Areas, Constants, Etc. ;
; ;
;---------------------------------------------------------------------------;
Version Db CR,'Switch Directory - DOS 1.0',CR,LF
Copyright Db 'Copyright (c) 1987, 1988 by Stephen M. Falatko',CR,LF
FakeEOF Db 26
Errlvl Db 0 ;DOS return code
;
; These are flags set by the command line processing
;
;
RootFlag Db 0 ; signal indicating default to root (0)
CDFlag Db 0 ; signal of specific path (1)
OneDeepFlag Db 0 ; search only current dir (1)
;
; This flag is set to indicate that a subdirectory has been found (ie if its
; 0 at the end then we did not find the subdirectory)
;
Done_Flag Db 0 ; found subdir during search
;
; If this flag is set then help is available if ? is entered on the
; command line
;
HelpFlag Db 1
;
; If this flag is set then we can use the internal stack feature
;
StackFlag Db 1
StackAddress Dw ProgramEndH
;
; The Stack_Pointer points to the internal stack path. This is initialized
; to 0 and changes depending on user input.
;
Stack_Pointer Db 0
InternalStackMsg Db CR,LF,'Internal Stack:',CR,LF,CR,LF,Stopper
Numbers Db ' 0 - ',0
Db ' 1 - ',0
Db ' 2 - ',0
Db ' 3 - ',0
Db ' 4 - ',0
Db ' 5 - ',0
Db ' 6 - ',0
Db ' 7 - ',0
Db ' 8 - ',0
Db ' 9 - ',0
CR_LF Db CR,LF,Stopper
;
; These variables hold the systems Ctrl-Break address so we can restore
; it when we exit
;
CtrlBrkOff Dw 0
CtrlBrkSeg Dw 0
;
; Here we will store the desired subdirectory (and drive if selected)
; as well as the original path and drive
;
Sub_Dir Db 63 Dup (0) ; The sub dir we want to change to
ScratchDirStart Db 'x:\' ; This is a scratch area for the
ScratchDir Db 63 Dup (0) ; GetDir function
OD LABEL Word
OrigDr Db 'x:' ; Original drive
OrigDir Db '\',63 Dup (0) ; and path
RootDir Db 'x:\',0 ; To get vol label
Count Dw 0 ; Number of args on command line
;
; These variables are used by the search routine
;
DtaPointer Dw DtaAreaBegin ; Pointer to our DTA area
Direction Db 0 ; Flag to indicate search subdirs
; of the current dir or not
BackOneDir Db '..',0 ; Asciiz 'filename' to backup
; one directory
SearchAsciiZ Db '*.*',0 ; Search filename
Old_INT_21 LABEL Dword ; Storage for previous INT 21
INT_21Off Dw ?
INT_21Seg Dw ?
FirstTime? Db 1 ; flag to signal first pass
; through INT 21 handler
Command_Addr Dw ? ; segment address of command.com
;
; We want to save the callers DS:DX in the INT 21 handler
;
Callers_DS Dw ? ; caller's data segment
Callers_DX Dw ? ; caller's dx register
CReturn Db 0D
CR_LFString Db 0D,0A,'$'
;
; Command is the string that we look for at the DOS prompt. It must
; be 8 characters long with the empty spaces blanks.
;
Command Db 'SD '
;
; Error messages
;
NoHelp Db CR,LF,'ERROR - Installed without help',CR,LF,Stopper
NoStack Db CR,LF,'ERROR - Installed without Stack feature',CR,LF,Stopper
ErrorMsgs Db CR,LF,'Illegal drive specifier - must be A to z',CR,LF,Stopper
Db CR,LF,'Maximum of 64 characters on command line',CR,LF,Stopper
Db CR,LF,'Illegal character on command line ',CR,LF,Stopper
Db CR,LF,'Currently in root directory ',CR,LF,Stopper
Db CR,LF,'Command line contains an invalid path ',CR,LF,Stopper
Db CR,LF,'Subdirectory Not Found ',CR,LF,Stopper
Db CR,LF,'Selected stack entry is empty ',CR,LF,Stopper
New_INT_21:
PUSH ES,DS,BP,SI,DI,AX,BX,CX,DX
;
; Is this a request for buffered input? If not go to next INT 21.
;
CMP AH,0A ; Function 0A (hex) ?
IF NE JMP Exit_INT_21 ; If not then let's leave ....
;
; Let's get the length of the original caller's buffer DS:DX points
; to caller's buffer with the first byte holding the maximum length.
;
MOV BX,DX
DS MOV CL,B [BX]
;
; Save DS and DX of calling program and make DS equal to CS
;
PUSH DS ; Store caller's DS
MOV DS,CS ; Change DS to CS
POP Callers_DS ; Pop caller's DS to Old_DS
PUSH DX ; Store caller's DX
POP Callers_DX
;
; We will use our command line for a buffer so copy the max length of the
; callers buffer to the first position of the new buffer
;
MOV BX,080 ; Point BX to the PSP command line
MOV B [BX],CL ; Store the buffer length in the
; first position
;
; Point the BP to the SP
;
MOV BP,SP
;
; Now, if it's the first time through here then COMMAND.COM is calling and we
; save the segment address off the stack. By doing this we can later
; verify if a caller is COMMAND.COM or not.
;
TEST FirstTime? ; If not the first time go on
JZ Not_First_Time
SS MOV BX,W [BP+4] ; Get COMMAND.COM's segment address
MOV Command_Addr,BX ; Save it
MOV FirstTime?,0 ; Clear flag
JMP Intercept
;
; If this is not the first time through then we want to see if the caller
; is COMMAND.COM or not.
;
Not_First_Time:
SS MOV BX,W [BP+4] ; Get caller's segment address
CMP BX,Command_Addr ; Compare it with COMMAND.COM'S
IF NE JMP Exit_INT_21 ; If its not the same go to next INT 21
;
; Now we know that the caller is DOS so let's get the user input into our
; own temporary buffer so we can check it against our commands.
;
; We begin by setting up a DOS call for buffered input.
;
Intercept:
MOV DX,080 ; Point DS:DX to our PSP
MOV AH,0A ; DOS function call 0A hex
PUSHF ; Simulate DOS interrupt
CALL Old_INT_21
;
; We have performed the caller's INT 21 call, now we must see if the
; entered command is one of ours or whether we must pass it on to COMMAND.COM
;
PUSHF ; First save the flags
CLD ; and clear the direction flag
;
; To simplify our comparison we will use DOS function 29 hex, parse filename,
; to strip leading blanks and capitalize the input string. We will store the
; result in the PSP FCB #1 location
;
MOV ES,CS ; Make ES equal CS
MOV SI,082 ; The source string starts in the PSP
MOV DI,05C